import { LOGOUT_CURRENT_PATH } from '/@/enum/cacheEnum.ts';

export enum PageEnum {
    BASE_LOGIN = '/login',
    BASE_HOME = '/home',
    BASE_LOGIN_YINCHUAN = '/screenLogin',
    // centralScreenLogin
    CENTRAL_SCREEN_LOGIN = '/centralScreenLogin',
    YINCHUAN_HOME = '/yinChuanHome',
    CENTRAL_SCREEN = '/centralScreen',
}

export function setBaseLogin(baseLogin) {
    localStorage.setItem('baseLogin', baseLogin);
}

export function getBaseLogin() {
    return localStorage.getItem('baseLogin');
}

//根据当前路径跳转登录页
export function toLoginByNowPath(nowPath: string) {
    const xianPath = ['/home', '/secondScreen', '/'];
    const yinchuanPath = ['/yinChuanHome', '/yinChuanTest'];
    //其他应急中心的页面路径
    const centerPath = ['/centralScreen', '/centralScreenLogin'];
    if (xianPath.includes(nowPath)) {
        return PageEnum.BASE_LOGIN;
    } else if (yinchuanPath.includes(nowPath)) {
        return PageEnum.BASE_LOGIN_YINCHUAN;
    } else if (centerPath.includes(nowPath)) {
        return PageEnum.CENTRAL_SCREEN_LOGIN;
    }
}

//根据退出时的页面路径跳转首页
export function toHomeByLogoutPath(nowPath: string) {
    //西安的页面路径
    const xianPath = ['/home', '/secondScreen', '/'];
    //银川的页面路径
    const yinchuanPath = ['/yinChuanHome', '/yinChuanTest'];
    //其他应急中心的页面路径
    const centerPath = ['/centralScreen'];
    if (xianPath.includes(nowPath)) {
        return PageEnum.BASE_HOME;
    } else if (yinchuanPath.includes(nowPath)) {
        return PageEnum.YINCHUAN_HOME;
    } else if (centerPath.includes(nowPath)) {
        return PageEnum.YINCHUAN_HOME;
    }
}

//缓存退出时的页面路径
export function setCurrentPath(nowPath) {
    localStorage.setItem(LOGOUT_CURRENT_PATH, nowPath);
}

export function getCurrentPath() {
    return localStorage.getItem(LOGOUT_CURRENT_PATH);
}
